<template>
  <div>
    <el-dialog :title="dialogDictItem.title" :visible.sync="dialogDictItem.show" width="30%" destroy-on-close @close='closeDialog' @open='openDialog'
               :close-on-click-modal="false" :close-on-press-escape="false" :append-to-body="true">
      <el-form ref="form" :model="formData" label-width="80px" :rules="rules">
          <el-form-item label="类型" prop="type">
            <el-input placeholder="请输入类型" v-model="formData.type" disabled></el-input>
          </el-form-item>
          <el-form-item label="数据值" prop="value" >
            <el-input placeholder="请输入数据值" v-model="formData.value"></el-input>
          </el-form-item>
          <el-form-item label="标签名" prop="label">
            <el-input placeholder="请输入标签名" v-model="formData.label"></el-input>
          </el-form-item>
          <el-form-item label="描述" prop="description">
            <el-input placeholder="请输入描述" v-model="formData.description"></el-input>
          </el-form-item>
          <el-form-item label="排序" prop="sort">
            <el-input type='number' :min="0" placeholder="排序" v-model="formData.sort"></el-input>
          </el-form-item>
          <el-form-item label="备注信息" prop="remarks">
            <el-input placeholder="备注信息" v-model="formData.remarks"></el-input>
          </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="resetForm('form')">取 消</el-button>
        <el-button type="primary" @click="handleSubmit('form')">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    dialogDictItem: Object,
    formData: Object
  },
  data() {
    return {
      systemKey: "",
      options: [
        {
          value: "1",
          label: "系统类",
        },
        {
          value: "2",
          label: "业务类",
        },
      ],
      rules: {
        type: [{ required: true, message: '请输入类型', trigger: 'blur' }],
        value: [{ required: true, message: '请输入数据值', trigger: 'blur' }],
        label: [{ required: true, message: '请输入标签名', trigger: 'blur' }],
        sort: [{ required: true, message: '请输入排序值', trigger: 'blur' }],
      }
    }
  },
  methods: {
    // 弹窗打开触发的方法
    openDialog() {
        
    },
    closeDialog() {

    },

    // 点击确定按钮触发
    handleSubmit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          if (this.dialogDictItem.option == 'add') {
            this.$emit("handleSubmit")
          } else {
            this.$emit("handleSubmitEdit")
          }
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    // 点击取消按钮触发
    resetForm(formName) {
      this.dialogDictItem.show = false
      this.$refs[formName].resetFields();
    }
  },
}
</script>

<style lang="scss" scoped>
</style>